home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / C++ / MPW C++ 3.1b1 / Examples / CPlusExamples / Shapes.h < prev    next >
Text File  |  1989-09-29  |  4KB  |  126 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    MultiFinder-Aware Simple Shapes Sample Application
  4. #
  5. #    CPlusShapesApp
  6. #
  7. #    This file: Shapes.h    -    Interface to the Shape Classes 
  8. #
  9. #    Copyright © 1988 Apple Computer, Inc.
  10. #    All rights reserved.
  11. #
  12. #    Versions:    1.0                 3/89
  13. #
  14. #    Components:
  15. #            CPlusShapesApp.make        March 1, 1989
  16. #            TApplicationCommon.h    March 1, 1989
  17. #            TApplication.h            March 1, 1989
  18. #            TDocument.h                March 1, 1989
  19. #            ShapesAppCommon.h        March 1, 1989
  20. #            ShapesApp.h                March 1, 1989
  21. #            ShapesDocument.h        March 1, 1989
  22. #            TApplication.cp            March 1, 1989
  23. #            TDocument.cp            March 1, 1989
  24. #            ShapesApp.cp            March 1, 1989
  25. #            ShapesDocument.cp        March 1, 1989
  26. #            TApplication.r            March 1, 1989
  27. #            ShapesApp.r                March 1, 1989
  28. #
  29. #   There are four main classes in this program. Each of
  30. #   these classes has a definition (.h) file and an
  31. #   implementation (.cp) file.  
  32. #   
  33. #   The TApplication class does all of the basic event
  34. #   handling and initialization necessary for Mac Toolbox
  35. #   applications. It maintains a list of TDocument objects,
  36. #   and passes events to the correct TDocument class when
  37. #   apropriate. 
  38. #   
  39. #   The TDocument class does all of the basic document
  40. #   handling work. TDocuments are objects that are
  41. #   associated with a window. Methods are provided to deal
  42. #   with update, activate, mouse-click, key down, and other
  43. #   events. Some additional classes which implement a
  44. #   linked list of TDocument objects are provided. 
  45. #   
  46. #   The TApplication and TDocument classes together define
  47. #   a basic framework for Mac applications, without having
  48. #   any specific knowledge about the type of data being
  49. #   displayed by the application's documents. They are a
  50. #   (very) crude implementation of the MacApp application
  51. #   model, without the sophisticated view heirarchies or
  52. #   any real error handling. 
  53. #   
  54. #   The TShapesApp class is a subclass of TApplication. It
  55. #   overrides several TApplication methods, including those
  56. #   for handling menu commands and cursor adjustment, and
  57. #   it does some necessary initialization.
  58. #   
  59. #   The TShapesDocument class is a subclass of TDocument. This
  60. #   class contains most of the special purpose code for
  61. #   shape drawing. In addition to overriding several of the
  62. #   TDocument methods, it defines a few additional
  63. #   methods which are used by the TShapesApp class to get
  64. #   information on the document state.  
  65. #
  66. #------------------------------------------------------------------------------*/
  67.  
  68. #ifndef Shape_Defs
  69. #define Shape_Defs
  70.  
  71. #include <Types.h>
  72. #include <QuickDraw.h>
  73. #include <stdlib.h>
  74.  
  75. class TShape : HandleObject {
  76.   public:
  77.     virtual void Move(Rect* r);        // Movement is not shape specific.
  78.     
  79.     // Neither Draw or Erase should ever be called, they MUST be overridden!
  80.     // We make them private and force an error so we'll know if this ever occurs.
  81.     virtual void Draw(Pattern)     {DebugStr("\pCall to TShape::Draw");}
  82.     virtual void Erase()          {DebugStr("\pCall to TShape::Erase");}
  83.   protected:
  84.     TShape(Rect* r);        // Only accessible to public descendants
  85.     Rect fBoundRect;
  86.   private:
  87.     virtual void RandomRect(Rect* drawRect);
  88. };
  89.  
  90. class TArc : public TShape {
  91.   public:
  92.     TArc(Rect* r);
  93.     
  94.     // Overridden since drawing and erasing are shape specific operations
  95.     virtual void Draw(Pattern);        
  96.     virtual void Erase();
  97.   private:
  98.     short fStartAngle, fArcAngle;    
  99. };
  100.  
  101.  
  102. class TRoundRect : public TShape {
  103.   public:
  104.     TRoundRect(Rect* r);
  105.     
  106.     // Overridden since drawing and erasing are shape specific operations
  107.      virtual void Draw(Pattern);
  108.     virtual void Erase();
  109.   private:
  110.     short fOvalWidth, fOvalHeight;        // curvature of rounded corners 
  111. };
  112.  
  113.  
  114. class TOval : public TShape {
  115.   public:
  116.     TOval(Rect *r);
  117.     
  118.     // Overridden since drawing and erasing are shape specific operations
  119.     virtual void Draw(Pattern);
  120.     virtual void Erase();
  121.   private:
  122.       short fStartAngle, fArcAngle;
  123. };
  124.  
  125. #endif Shape_Defs
  126.